package com.silverhaze.diamond.client.ui.filter;

import com.silverhaze.diamond.client.ui.UIStringConstants;
import com.silverhaze.diamond.client.ui.table.model.AbstractServiceTableModel;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * © Ivan Babanin (aka JavaBean) (21.07.2007 1:24:56)
 */
public abstract class AbstractFilterPanel extends JPanel {
    private AbstractServiceTableModel model;
    private JToggleButton tButton;

    public AbstractFilterPanel(AbstractServiceTableModel model, JToggleButton tBtn) {
        setLayout(new BorderLayout());

        this.model = model;
        this.tButton = tBtn;

        this.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() >= 2) {
                    AbstractFilterPanel.this.setVisible(false);
                    getTButton().setSelected(false);
                }
            }
        });


        TitledBorder tBorder = new TitledBorder(" " + UIStringConstants.FILTER + " ");
        setBorder(tBorder);
    }

    public AbstractServiceTableModel getModel() {
        return model;
    }

    public JToggleButton getTButton() {
        return tButton;
    }
}

